#include <iostream>
#include <vector>
#include <string>
using namespace std;

class Solution {
public:
    int compress(vector<char>& chars) {
        string str; // 总的字符串
        str.push_back(chars[0]);
        int countChar = 1;
        for (int idx = 1; idx < chars.size(); idx++) {
            if (chars[idx] == str.back()) {
                countChar++;
            } else {
                if ((countChar != 0) && (countChar != 1)) {
                    string tmp = to_string(countChar);
                    str += tmp;
                }
                str.push_back(chars[idx]);
                countChar = 1;
            }
        }
        if ((countChar != 0) && (countChar != 1)) {
            string tmp = to_string(countChar);
            str += tmp;
        }
        cout << "str : " << str << endl;
        chars.clear();
        for (auto ch : str) {
            chars.push_back(ch);
        }
        return chars.size();
    }
};

int main()
{   
    Solution s;
    vector<char> chars{'a','a','b','b','b','b','a','a','b','b','b','b','b','b'};
    cout << s.compress(chars) << endl;
    return 0;
}